package j.framework.core.entity;

import j.framework.core.DataType;

import java.util.Date;

/**
 * 实体属性
 * Created by junhai on 2015/2/25.
 */
public class EntityProperty implements java.io.Serializable{
    public static final String DATA_INPUT_TYPE_PHONE = "PHONE";
    public static final String DATA_INPUT_TYPE_MOBILE = "MOBILE";
    public static final String DATA_INPUT_TYPE_IDCARD = "IDCARD";
    public static final String DATA_INPUT_TYPE_EMAIL = "EMAIL";
    public static final String DATA_INPUT_TYPE_URL = "URL";
    public static final String DATA_INPUT_TYPE_REGEX = "REGEX";
    public static final String DATA_INPUT_TYPE_DICT = "DICT";
    private String entityId;
    private String fieldName;

    private String sequenceKey;

    private String labelName;//标签名称

    private boolean isDesEncrypted;//此字段是否des加密，若是，则封装数据时加密，接收数据时解密

    private boolean logChanged;

    private DataType dataType;//数据类型

    private Object defaultValue;//默认值，已将数据库中的默认值转换成正确的数据类型

    private boolean isRequired;//是否必填项

    private String minValue;
    private String maxValue;

    private Integer minIntValue;
    private Integer maxIntValue;

    private Float minFloatValue;
    private Float maxFloatValue;

    private Double minDoubleValue;
    private Double maxDoubleValue;

    private Date minDateValue;
    private Date maxDateValue;

    private String dataInputType;
    private String dataInputOptions;

    private boolean updatable;
    private boolean insertable;

    private boolean isDeletedFieldTag;

    public String getEntityId() {
        return entityId;
    }
    public void setEntityId(String entityId) {
        this.entityId = entityId;
    }

    public String getFieldName() {
        return fieldName;
    }
    public void setFieldName(String fieldName) {
        this.fieldName = fieldName;
    }

    public String getSequenceKey() {
        return sequenceKey;
    }
    public void setSequenceKey(String sequenceKey) {
        this.sequenceKey = sequenceKey;
    }

    public String getLabelName() {
        return labelName;
    }
    public void setLabelName(String labelName) {
        this.labelName = labelName;
    }

    public boolean isDesEncrypted() {
        return isDesEncrypted;
    }
    public void setDesEncrypted(boolean isDesEncrypted) {
        this.isDesEncrypted = isDesEncrypted;
    }

    public boolean isLogChanged() {
        return logChanged;
    }
    public void setLogChanged(boolean logChanged) {
        this.logChanged = logChanged;
    }

    public DataType getDataType() {
        return dataType;
    }
    public void setDataType(DataType dataType) {
        this.dataType = dataType;
    }

    public Object getDefaultValue() {
        return defaultValue;
    }
    public void setDefaultValue(Object defaultValue) {
        this.defaultValue = defaultValue;
    }

    public boolean isRequired() {
        return isRequired;
    }
    public void setRequired(boolean isRequired) {
        this.isRequired = isRequired;
    }

    public String getMinValue() {
        return minValue;
    }
    public void setMinValue(String minValue) {
        this.minValue = minValue;
    }

    public String getMaxValue() {
        return maxValue;
    }
    public void setMaxValue(String maxValue) {
        this.maxValue = maxValue;
    }

    public Integer getMinIntValue() {
        return minIntValue;
    }
    public void setMinIntValue(Integer minIntValue) {
        this.minIntValue = minIntValue;
    }

    public Integer getMaxIntValue() {
        return maxIntValue;
    }
    public void setMaxIntValue(Integer maxIntValue) {
        this.maxIntValue = maxIntValue;
    }

    public Float getMinFloatValue() {
        return minFloatValue;
    }
    public void setMinFloatValue(Float minFloatValue) {
        this.minFloatValue = minFloatValue;
    }

    public Float getMaxFloatValue() {
        return maxFloatValue;
    }
    public void setMaxFloatValue(Float maxFloatValue) {
        this.maxFloatValue = maxFloatValue;
    }

    public Double getMinDoubleValue() {
        return minDoubleValue;
    }
    public void setMinDoubleValue(Double minDoubleValue) {
        this.minDoubleValue = minDoubleValue;
    }

    public Double getMaxDoubleValue() {
        return maxDoubleValue;
    }
    public void setMaxDoubleValue(Double maxDoubleValue) {
        this.maxDoubleValue = maxDoubleValue;
    }

    public Date getMinDateValue() {
        return minDateValue;
    }
    public void setMinDateValue(Date minDateValue) {
        this.minDateValue = minDateValue;
    }

    public Date getMaxDateValue() {
        return maxDateValue;
    }
    public void setMaxDateValue(Date maxDateValue) {
        this.maxDateValue = maxDateValue;
    }

    public String getDataInputType() {
        return dataInputType;
    }
    public void setDataInputType(String dataInputType) {
        this.dataInputType = dataInputType;
    }

    public String getDataInputOptions() {
        return dataInputOptions;
    }
    public void setDataInputOptions(String dataInputOptions) {
        this.dataInputOptions = dataInputOptions;
    }

    public boolean isUpdatable() {
        return updatable;
    }
    public void setUpdatable(boolean updatable) {
        this.updatable = updatable;
    }

    public boolean isInsertable() {
        return insertable;
    }
    public void setInsertable(boolean insertable) {
        this.insertable = insertable;
    }

    public boolean isDeletedFieldTag() {
        return isDeletedFieldTag;
    }
    public void setDeletedFieldTag(boolean isDeletedFieldTag) {
        this.isDeletedFieldTag = isDeletedFieldTag;
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;

        EntityProperty that = (EntityProperty) o;

        if (fieldName != null ? !fieldName.equals(that.fieldName) : that.fieldName != null) return false;

        return true;
    }

    @Override
    public int hashCode() {
        return fieldName != null ? fieldName.hashCode() : 0;
    }
}
